import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home/index',
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    children: [{
      path: 'index',
      name: '/home/index',
      component: () => import('../views/Index.vue'),
      meta: {
        breadcrumbs: ['首页']
      }
    },{
      path: 'actor-list',
      name: '/home/actor-list',
      component: () => import('../views/actor/ActorList.vue'),
      // meta称为路由对象的元数据，在此处可以自定义配置一些路由相关参数
      // 方便在组件中使用
      meta: {
        // 在此自定义一个meta数据，保存当前路由应显示的面包屑导航列表
        breadcrumbs: ['演员管理', '演员列表']
      }
    },{
      path: 'actor-add',
      name: '/home/actor-add',
      component: () => import('../views/actor/ActorAdd.vue'),
      meta: {
        breadcrumbs: ['演员管理', '添加演员']
      }
    },{
      path: 'director-list',
      name: '/home/director-list',
      component: () => import('../views/director/DirectorList.vue'),
      meta: {
        breadcrumbs: ['导演管理', '导演列表']
      }
    },{
      path: 'director-add',
      name: '/home/director-add',
      component: () => import('../views/director/DirectorAdd.vue'),
      meta: {
        breadcrumbs: ['导演管理', '添加导演']
      }
    },{
      path: 'movie-list',
      name: '/home/movie-list',
      component: () => import('../views/movie/MovieList.vue'),
      meta: {
        breadcrumbs: ['电影管理', '电影列表']
      }
    },{
      path: 'movie-add',
      name: '/home/movie-add',
      component: () => import('../views/movie/MovieAdd.vue'),
      meta: {
        breadcrumbs: ['电影管理', '添加电影']
      }
    },{
      // 该路由末尾接收电影id参数，
      // 匹配：/home/movie-update/135
      path: 'movie-update/:id',
      name: '/home/movie-update',
      component: () => import('../views/movie/MovieUpdate.vue'),
      meta: {
        breadcrumbs: ['电影管理', '电影列表', '修改电影']
      }
    },{
      path: 'cinema-list',
      name: '/home/cinema-list',
      component: () => import('../views/cinema/CinemaList.vue'),
      meta: {
        breadcrumbs: ['影院管理', '影院列表']
      }
    },{
      path: 'cinema-add',
      name: '/home/cinema-add',
      component: () => import('../views/cinema/CinemaAdd.vue'),
      meta: {
        breadcrumbs: ['影院管理', '添加影院']
      }
    },{
      // 匹配： /home/cinema-room-list/3
      path: 'cinema-room-list/:cinemaId',
      name: '/home/cinema-room-list',
      component: () => import('../views/cinema/CinemaRoomList.vue'),
      meta: {
        breadcrumbs: ['影院管理', '影院列表', '放映厅列表']
      }
    },{
      // 匹配： /home/showingon-plan-add/3
      path: 'showingon-plan-add/:roomId',
      name: '/home/showingon-plan-add',
      component: () => import('../views/cinema/ShowingonPlanAdd.vue'),
      meta: {
        breadcrumbs: ['影院管理', '影院列表', '放映厅列表', '添加排片计划']
      }
    }]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
